import { Token } from "@/types/data";
import { LoginAction } from "@/types/store";
import { getToken } from "@/utils/storage";

const initialState: Token = getToken();

export default function login(state = initialState, action: LoginAction): Token {
  if (action.type === 'login/login') {
    return action.payload;
  }
  if (action.type === 'login/logout') {
    return {
      token: '',
      refresh_token: ''
    }
  }
  return state;
}
